package com.caifu.controller.healthArchive;


import com.caifu.controller.AbstractController;
import com.caifu.pojo.SysUser;
import com.caifu.service.IHealthArchiveService;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 *
 * 功能描述：老人血压记录
 *
 * @Author  GZ
 * @Date   2020/11/19 17:34
 */
@Controller
@RequestMapping("/healthArchive/bloodPressure")
public class BloodPressureController extends AbstractController {

    @Autowired
    private IHealthArchiveService archiveService;

    /**
    * 
    * 功能描述：查询血压条记录信息
    *
    * @Author  GZ
    * @Date   2020/11/19 13:54
    */
    @RequestMapping("obtainData")
    @ResponseBody
    public JSONObject obtainData(int pageNum, int pageSize
            , String startDate, String endDate, String userNo){
        try {
            return archiveService.pagedQueryUserBloodPressureInfo(
                    pageNum,pageSize,startDate,endDate,userNo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     *
     * 功能描述：保存血压信息
     *
     * @Author  GZ
     * @Date   2020/11/17 17:37
     */
    @RequestMapping("saveData")
    @ResponseBody
    public JSONObject saveData(String userNo, String systolicPressure
            , String diastolicPressure){
        SysUser sysUser =getUser();
        try {
            return archiveService
                    .saveBloodPressureInfo(userNo,systolicPressure,diastolicPressure,sysUser);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
    /**
     *
     * 功能描述：删除选中的记录
     *
     * @Author  GZ
     * @Date   2020/11/19 10:51
     */
    @RequestMapping("deleteData")
    @ResponseBody
    public JSONObject deleteData(String dataInfo){
        try {
            return archiveService.deleteBloodPressure(dataInfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
